<?php

namespace App\Utils\Service;

use Illuminate\Support\Facades\Log;
use MongoDB\Client;

/**
 * 连接mongo
 * gao
 */
class MongoDB
{
    /**
     * mongodb添加一条数据
     * @param $data
     * @return void
     */
    public static function insertOne($data)
    {
        //连接MongoDB数据库
        $client = new Client("mongodb://localhost:27017");
        //库名->集合名
        $collection = $client->wechat->wechat;
        //添加一条数据
        $result = $collection->insertOne($data);
        if (!$result) Log::info('存储失败');
        return $result;
    }

}
